package com.sjsu.CMPE226.normalized.hibernate.data;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "stations_info")
public class Station {
	@Id
	
	// @GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "Station_Id", updatable = false, nullable = false)
	private String stationId;

	@Column(name = "Secondary_Station_Id", nullable = true)
	private String secondaryStationId;
	
	@Column(name = "Station_Name", nullable = true)
	private String stationName;

	@Column(name = "Status", nullable = true)
	private String status;

	@Column(name = "State", nullable = true)
	private String state;

	@Column(name = "Country", nullable = true)
	private String country;

	@Column(name = "Latitude", nullable = true)
	private double latitude;

	@Column(name = "Longitude", nullable = true)
	private double longitude;

	@Column(name = "Elevation", nullable = true)
	private float elevation;

	@Column(name = "Wims_Id", nullable = true)
	private int wimsId;

	@ManyToOne
    @JoinColumn(name = "Network_Id", nullable = false)
	private Network network;

	@ManyToOne
    @JoinColumn(name = "Primary_Provider_Id", nullable = false)
	private Provider primaryProvider;
	
	@ManyToOne
    @JoinColumn(name = "Secondary_Provider_Id", nullable = false)
	private Provider secondaryProvider;
	
	@ManyToOne
    @JoinColumn(name = "Tertiary_Provider_Id", nullable = false)
	private Provider tertiaryProvider;
	

	public Station() {

	}

	public int getWimsId() {
		return wimsId;
	}

	public void setWimsId(int wimsId) {
		this.wimsId = wimsId;
	}

	public Network getNetwork() {
		return network;
	}

	public void setNetworkId(Network network) {
		this.network = network;
	}

	public Provider getPrimaryProvider() {
		return primaryProvider;
	}

	public void setPrimaryProvider(Provider primaryProvider) {
		this.primaryProvider = primaryProvider;
	}

	public Provider getSecondaryProvider() {
		return secondaryProvider;
	}

	public void setSecondaryProvider(Provider secondaryProvider) {
		this.secondaryProvider = secondaryProvider;
	}

	public Provider getTertiaryProvider() {
		return tertiaryProvider;
	}

	public void setTertiaryProvider(Provider tertiaryProvider) {
		this.tertiaryProvider = tertiaryProvider;
	}

	public String getStationId() {
		return stationId;
	}

	public void setStationId(String stationId) {
		this.stationId = stationId;
	}

	public String getSecondaryStationId() {
		return secondaryStationId;
	}

	public void setSecondaryStationId(String secondaryStationId) {
		this.secondaryStationId = secondaryStationId;
	}

	public String getStationName() {
		return stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	public float getElevation() {
		return elevation;
	}

	public void setElevation(float elevation) {
		this.elevation = elevation;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((country == null) ? 0 : country.hashCode());
		result = prime * result + Float.floatToIntBits(elevation);
		long temp;
		temp = Double.doubleToLongBits(latitude);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(longitude);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((network == null) ? 0 : network.hashCode());
		result = prime * result
				+ ((primaryProvider == null) ? 0 : primaryProvider.hashCode());
		result = prime
				* result
				+ ((secondaryProvider == null) ? 0 : secondaryProvider
						.hashCode());
		result = prime
				* result
				+ ((secondaryStationId == null) ? 0 : secondaryStationId
						.hashCode());
		result = prime * result + ((state == null) ? 0 : state.hashCode());
		result = prime * result
				+ ((stationId == null) ? 0 : stationId.hashCode());
		result = prime * result
				+ ((stationName == null) ? 0 : stationName.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime
				* result
				+ ((tertiaryProvider == null) ? 0 : tertiaryProvider.hashCode());
		result = prime * result + wimsId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Station other = (Station) obj;
		if (country == null) {
			if (other.country != null)
				return false;
		} else if (!country.equals(other.country))
			return false;
		if (Float.floatToIntBits(elevation) != Float
				.floatToIntBits(other.elevation))
			return false;
		if (Double.doubleToLongBits(latitude) != Double
				.doubleToLongBits(other.latitude))
			return false;
		if (Double.doubleToLongBits(longitude) != Double
				.doubleToLongBits(other.longitude))
			return false;
		if (network == null) {
			if (other.network != null)
				return false;
		} else if (!network.equals(other.network))
			return false;
		if (primaryProvider == null) {
			if (other.primaryProvider != null)
				return false;
		} else if (!primaryProvider.equals(other.primaryProvider))
			return false;
		if (secondaryProvider == null) {
			if (other.secondaryProvider != null)
				return false;
		} else if (!secondaryProvider.equals(other.secondaryProvider))
			return false;
		if (secondaryStationId == null) {
			if (other.secondaryStationId != null)
				return false;
		} else if (!secondaryStationId.equals(other.secondaryStationId))
			return false;
		if (state == null) {
			if (other.state != null)
				return false;
		} else if (!state.equals(other.state))
			return false;
		if (stationId == null) {
			if (other.stationId != null)
				return false;
		} else if (!stationId.equals(other.stationId))
			return false;
		if (stationName == null) {
			if (other.stationName != null)
				return false;
		} else if (!stationName.equals(other.stationName))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (tertiaryProvider == null) {
			if (other.tertiaryProvider != null)
				return false;
		} else if (!tertiaryProvider.equals(other.tertiaryProvider))
			return false;
		if (wimsId != other.wimsId)
			return false;
		return true;
	}
	
}